import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:bookapp/helpers/adapt.dart';
import 'package:bookapp/helpers/constants.dart';

class ListItem extends StatelessWidget {
  final String title;
  final String? subTitle;
  final double height;
  final Widget rightWidget;
  final GestureTapCallback? onTap;

  ListItem({required this.title, this.subTitle, this.height = 80.0, this.rightWidget = const SizedBox(),this.onTap});

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: this.onTap,
      child: Container(
        padding: EdgeInsets.only(right: Constants.pageMargin),
        margin: EdgeInsets.only(right: Constants.pageMargin),
        height:Adapt.height(height),
        decoration: BoxDecoration(
          border: Border(
            bottom: BorderSide(
              width: Adapt.width(0.5),
              color: Color(AppColors.borderColor),
            ),
          ),
        ),
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: <Widget>[
            subTitle == null ?
                Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    Text(
                      title,
                      style: TextStyle(
                        color: Color(AppColors.fontColor),
                        fontSize: Adapt.px(16.0),
                      ),
                    ),
                  ],
                ) :
                Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Text(
                      title,
                      style: TextStyle(
                        color: Color(AppColors.fontColor),
                        fontSize: Adapt.px(16.0),
                      ),
                    ),
                    SizedBox(
                      height:Adapt.height(4.0),
                    ),
                    Text(
                      subTitle!,
                      style: TextStyle(
                        color: Color(AppColors.fontColorGray),
                      ),
                    ),
                  ],
                ),
            this.rightWidget,
          ],
        ),
      ),
    );
  }
}
